/* 
*  Copyright (C) 2009-2010 WCG Project
*
*  This program is free software; you can redistribute it and/or modify it
*  under the terms of the GNU General Public License as published by the
*  Free Software Foundation; either version 2 of the License, or (at
*  your option) any later version.
*
*  This program is distributed in the hope that it will be useful, but
*  WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
*  General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*  In addition, as a special exception, the author gives permission to
*  link the code of this program with the Half-Life Game Engine ("HL
*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
*  L.L.C ("Valve"). You must obey the GNU General Public License in all
*  respects for all of the code used other than the HL Engine and MODs
*  from Valve. If you modify this file, you may extend this exception
*  to your version of the file, but you are not obligated to do so. If
*  you do not wish to do so, delete this exception statement from your
*  version.
*/



enum
{
	TASK_GLOBAL_HEARTBEAT = 1000,	// Task numbers starts at 1000
	TASK_BUYTIME,					// Checks for buytime
	TASK_EXECUTECONFIG,
	TASK_AFTERCONFIG,
	TASK_SETSQL,
	TASK_RESETSPAWNS,
	TASK_DELAYED_DAMAGE,
	TASK_DELAYEDFUNCTION[33],		// Used to call delayed function for individual id's (never removed)
	TASK_EFFECT[33],				// These tasks will always be removed on new round
	TASK_ALIVE_EFFECT[33],			// These tasks will always be removed on user death as well as on user spawn
	TASK_FORCERACESELECT[33],
	TASK_SPAWN[33],					// Respawning from revive
	TASK_STEALTH[33],
	TASK_REMOVEPOLYCHICKEN[33],
	TASK_REMOVEFROSTNOVA[33],
	TASK_BANISH[33],				// Used to set the user's origin back to normal
	TASK_GETINPUT[33],				// Calls getuserinput function
	TASK_WAVE[33],					// Healing Wave
	TASK_GLOW[33],					// Calls glow_change
	TASK_HEX[33],					// Jumper task (goomba)
	TASK_RESETSPEED[33],			// Reset maxspeed (bash)
	TASK_ITEM_GLOVES[33],			// Nade timer (gloves)
	TASK_BLINKSTUCK[33],			// Checks to see if a user is stuck after blinking
	TASK_TELEPORT[33],				// For teleporting someone w00t
	TASK_LIGHTNING[33],				// Used for chain lightning
	TASK_LIGHTNINGNEXT[33],			// Used for chain lightning
	TASK_SPAWNPLAYER[33],			// Used to spawn a player (final spawn call)
	TASK_ITEM_RING[33],				// Used with rings of regeneration
	TASK_LIGHT[33],					// Used with serpant wards
	TASK_FUNNELS[33],				// Used with Swarming Locusts
	TASK_SAVE[33],					// Used for saving XP
	TASK_CASTINGSPELL[33],			// Used for casting spells
	TASK_CASTINGINTERRUPTCHECK[33],	// Used to check for spellcasting interruptions
	TASK_SEARCHPING[33],			// Used to play the "ping" sound every second
	TASK_BURNING[33],				// Used for Blood Mage Ultimate
	TASK_TRANQUILITY[33]			// Used to give tranquility effect on players
}


#define ARMOR_RATIO	 0.70	// Armor Takes 30% of the damage (was .2 in the SDK)
#define ARMOR_BONUS  0.55


/*	 Weapon IDs	 */
enum 
{
	CSW_WORLDSPAWN = 0,
	CSW_WAR3_MIN = 50,
	CSW_LIGHTNING,
	CSW_CRITICAL_GRENADE,
	CSW_FROSTNOVA_GRENADE,
	CSW_IMMOLATE,
	CSW_SERPENTWARD,
	CSW_SMITE,
	CSW_THORNS,
	CSW_BLASTWAVE,
	CSW_SERPENTSTING,
	CSW_ARCANESHOT,
	CSW_BANISH,
	CSW_ENTANGLE,
	CSW_BEASTWITHIN_GRENADE,
	CSW_WAR3_MAX
}


// New team ID defines
#define TEAM_UNASSIGNED	0
#define TEAM_T			1
#define TEAM_CT			2
#define TEAM_SPECTATOR	3

// To determine what game is running
#define GAME_CSTRIKE	1
#define GAME_CZERO		2

// Used with PB_SKINSWITCHED
#define SKIN_RESET		0
#define SKIN_SWITCH		1


#define INVIS_CLOAK_DIVISOR			1.15

// For Icon events
#define ICON_HIDE 			0 
#define ICON_SHOW 			1 
#define ICON_FLASH 			2 

#define MAX_LEVELS			50



enum	// Holds information about the player
{
	PLR_BOMB_DEFUSER = 1,
	PLR_BOMB_PLANTER,
	PLR_HOSTAGE_RESCUER,
	PLR_VIP,
	PLR_BOMB_CARRIER,
}


// What is the user going to respawn by?
#define RESPAWN_ITEM				1
#define RESPAWN_RESURRECT			2
#define RESPAWN_SOULSTONE			3

#define IMMUNITY_RADIUS				500		// Enemies who have immunity w/in this radius will cause blink to fail 
#define SPAWN_DELAY					0.2
#define MAX_CASTING_VELOCITY		40.0	// If players velocity is greater then this, any spellcasting will be interrupted


// thanks twistedeuphoria - from objective proximity warning
#define MAX_OBJECTIVES				11
#define OBJENT_VIP_ESCAPE			0
#define OBJENT_HOSTAGE				1
#define OBJENT_BOMBSITE				2
#define OBJENT_HOSTAGE_ESCAPE		3


// Race numbers. Codes are used when saving		*** DO NOT CHANGE THE ID's ***
#define CLASS_GLOBAL				255			// Used for skills accessable by all classes
#define CLASS_NONE					0
#define CLASS_ROGUE					1
#define CLASS_PALADIN				2
#define CLASS_SHAMAN				3
#define CLASS_DRUID					4
#define CLASS_WARLOCK				5
#define CLASS_HUNTER				6
#define CLASS_PRIEST				7
#define CLASS_MAGE					8
#define MAX_CLASSES					8


// SKILL DEFINES. Codes are used when saving	*** DO NOT CHANGE THE ID's ***
#define SKILL_NONE						-1
#define SKILL_EVASION					0
#define SKILL_SPRINT					1
#define SKILL_LEVITATION				2
#define ULTIMATE_STEALTH				3
#define SKILL_INVISIBILITY				4
#define SKILL_DEVOTION					5
#define SKILL_HOJ						6
#define ULTIMATE_BLINK					7
#define SKILL_CRITICALSTRIKE			8
#define SKILL_CRITICALGRENADE			9
#define SKILL_REINCARNATION				10
#define ULTIMATE_CHAINLIGHTNING			11
#define SKILL_QUICKNESS					12
#define SKILL_THORNS					13
#define SKILL_TRUESHOT					14
#define ULTIMATE_ENTANGLE				15
#define SKILL_RESURRECT					16
#define SKILL_BANISH					17
#define SKILL_SIPHONMANA				18
#define ULTIMATE_IMMOLATE				19
#define SKILL_DEMONARMOR				20
#define SKILL_ARCANESHOT				21
#define SKILL_WINGCLIP					22
#define ABILITY_SERPENTWARD				23
#define ULTIMATE_DIVINEPROTECTION		24
#define SKILL_SERPENTSTING				25
#define SKILL_VAMPIRICEMBRACE			26
#define SKILL_FORTITUDE					27
#define SKILL_SMITE						28
#define SKILL_SOULSTONE					29
#define SKILL_INNERFIRE					30
#define SKILL_FROSTBOLT					31
#define SKILL_FROSTARMOR				32
#define SKILL_BLASTWAVE					33
#define ABILITY_POLYCHICKEN				34
#define SKILL_FROSTNOVA					35
#define ABILITY_TRANQUILITY				36
#define SKILL_IMPROVEDCRITICALSTRIKE	37
#define SKILL_IMPROVEDSIPHONMANA		38
#define SKILL_CHEATDEATH				39
#define ABILITY_CHAINHEAL				40
#define ULTIMATE_BINDINGHEAL			41
#define ABILITY_HOLYLIGHT				42
#define SKILL_BOK						43
#define ULTIMATE_BEASTWITHIN			44
#define SKILL_AMBUSH					45
#define MAX_SKILLS						46


// ATTRIBUTE DEFINES. Codes are used when saving	*** DO NOT CHANGE THE ID's ***
#define ATTRIBUTE_NONE					-1
#define ATTRIBUTE_STR					0
#define ATTRIBUTE_STA					1
#define ATTRIBUTE_DEX					2
#define ATTRIBUTE_AGI					3
#define ATTRIBUTE_INT					4
#define ATTRIBUTE_SPR					5
#define MAX_ATTRIBUTES					6

#define MAX_ATTRIBUTELEVEL				15





// Item Charge Defines
#define NECKLACE_CHARGES	4
#define HELM_CHARGES		3
#define CHARGE_DISPOSE      1
#define RING_INCREMENT      1

// Item Variable Defines
#define MAX_SHOPMENU_ITEMS  18
#define MAX_PLAYER_ITEMS    2
#define MAX_PAGE_ITEMS      9
#define ITEM_SLOT_ONE       0
#define ITEM_SLOT_TWO       1
#define ITEM_SLOT_FULL      2

#define ITEM_NONE          -1
#define ITEM_ANKH		    0
#define ITEM_BOOTS		    1
#define ITEM_CLAWS		    2
#define ITEM_CLOAK		    3
#define ITEM_MASK		    4
#define ITEM_NECKLACE	    5
#define ITEM_FROST		    6
#define ITEM_HEALTH		    7
#define ITEM_TOME		    8
#define ITEM_SCROLL		    9
#define ITEM_PROTECTANT     10
#define ITEM_HELM		    11
#define ITEM_AMULET		    12
#define ITEM_SOCK		    13
#define ITEM_GLOVES		    14
#define ITEM_RING		    15
#define ITEM_CHAMELEON	    16
#define ITEM_MOLE		    17

#define MAX_ITEMS_PAGE		9

#define ITEM_CHARGEABLE		1
#define ITEM_USEONBUY		2
#define ITEM_BUYWHENDEAD	4
#define ITEM_NEXTROUNDUSE	8

#define ITEM_COST_RATIO		1.0








#define STARTING_MANA					50.0	// Amount of mana spawning players starts with

// Used with g_SkillType
#define SKILL_TYPE_TRAINABLE		1
#define SKILL_TYPE_ULTIMATE			3
#define SKILL_TYPE_ABILITY			4


// SOUNDS
enum
{
	SOUND_NULL,
	SOUND_BANISH,
	SOUND_VOODOO,
	SOUND_ENTANGLINGSTART,
	SOUND_ENTANGLINGEND,
	SOUND_LIGHTNING,
	SOUND_WINGCLIP,
	SOUND_IMMOLATE,
	SOUND_IMMOLATE_BURNING,
	SOUND_LEVELUP,
	SOUND_PICKUPITEM,
	SOUND_TOME,
	SOUND_ULTIMATESCAN,
	SOUND_ULTIMATEREADY,
	SOUND_REINCARNATION,
	SOUND_ANTEND,
	SOUND_ERROR,
	SOUND_DISPELL,
	SOUND_SPELLSHIELD,
	SOUND_TRANQUILITY,
	SOUND_STRIKE,
	SOUND_HEAL_LOW_BASE,
	SOUND_PRECAST_HOLY,
	SOUND_CAST_HOLY,
	SOUND_STEALTH,
	SOUND_TELEPORT,
	SOUND_POLYMORPHCHICKEN,
	SOUND_KILLCHICKEN,
	SOUND_BLIZZARDIMPACT,
	SOUND_FROSTNOVA,
	SOUND_FIRENOVA,
	SOUND_RESURRECT,
	SOUND_SOULSTONE,
	SOUND_FLASH_HEAL,
	SOUND_HOLYBOLT,
	SOUND_FORTITUDE,
	SOUND_SERPENTSTING,
	SOUND_ARCANEMISSILE,
	SOUND_DECISIVESTRIKE,
	SOUND_RESISTANCEAURA,
	SOUND_BLOODLUST,
//	SOUND_AMBUSH,
	MAX_SOUNDS
}


// SPRITES
enum
{
	SPR_BANISH,
	SPR_SHADOWSTRIKE,
	SPR_SNOW,
	SPR_FIRE,
	SPR_BURNING,
	SPR_BEETLE,
	SPR_FIREBALL,
	SPR_BEAM,
	SPR_TRAIL,
	SPR_SHOCKWAVE,
	SPR_LIGHTNING,
	SPR_FLARE,
	SPR_WAVE,
	SPR_SMOKE,
	SPR_IMMOLATE,
	MAX_SPRITES
}



// HUD Channels
#define HUD_SPEC_INFO			7			// Info displayed in bottom corner of player being spectated
#define HUD_SHOWSTATUS			6 // 4		// Information shown on enemies/teammates when looking at them
#define HUD_RACE_INFO			2			// /level command
#define HUD_ULTIMATE			1			// Ultimate messages (i.e. you have _ seconds remaining)
#define HUD_SKILL				3			// i.e. "you have evaded a shot"
#define HUD_XP					3			// Used to show the user their xp/items when dead
#define HUD_AUTO				-1			// Automatically choose one!
#define HUD_TIMER				1			// Timer
#define HUD_CASTING				5


enum
{
	TXT_OTHER,
	TXT_TOP_CENTER,
	TXT_RACE_INFO,
	TXT_ULTIMATE,
	TXT_BLINK_CENTER,
	TXT_SKILL,
	TXT_TIMER,
	TXT_CASTING
}

#define HUDMESSAGE_FX_FADEIN    0			// hudmessage effect types
#define HUDMESSAGE_FX_FLICKER   1
#define HUDMESSAGE_FX_WRITEOUT  2

#define SPEC_HOLDTIME			10.0	// Used for spectating info


enum
{
	SPELL_ERROR_COOLDOWN,
	SPELL_ERROR_PLANTDEFUSE,
	SPELL_ERROR_STUNNED,
	SPELL_ERROR_HEXED,
	SPELL_ERROR_POLYMORPHED,
	SPELL_ERROR_NO_MANA
}


// Cast types used by PLAYER_CastSpell() function
enum
{
	CAST_NORMAL,						// Normal casting
	CAST_PASSIVE,						// Used by "reacting" spells like shadowstrike
	CAST_SEARCH							// Used for searching spells, like ultimates
}

// Flags used by PLAYER_CastSpell() function
enum (<<=1)
{
	CAST_IGNORE_PLANT_DEFUSE = 1,		// Ignores the plant/defuse check
	CAST_IGNORE_INTERRUPT,				// Ignores if the players casting gets interrupted
	CAST_IGNORE_STUNNED,				// Skips over the stunned player check
	CAST_IGNORE_HEXED,					// Skips over the hexed player check
	CAST_IGNORE_MOVEMENT,				// Skips checking if the player is moving or not
	CAST_IGNORE_COOLDOWN,				// Ignores if the spell is on cooldown or not
	CAST_IGNORE_MANA_COST,				// Ignores checking the mana cost for the spell
	CAST_HIDE_MANA_WARNING,				// Doesn't show the out of mana text on the hud
	CAST_SKIP_SET_COOLDOWN,				// Skips triggering cooldown for the spell
	CAST_SKIP_SET_MANA_COST,			// Skips reducing the players mana
	CAST_SKIP_ENDCAST_SOUND,			// Doesn't play the cast sound when a spell goes off
	CAST_SEARCH_OPPOSITE_TEAM,			// Triggers search success if the target is on the opposite team
	CAST_SEARCH_SAME_TEAM,				// Triggers search success if the target is on the same team
	CAST_SIMULATE						// Only simulates the cast returning proper true or false for successful casts
}



// NOTE: It's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage.
// DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead.
#define DMG_GENERIC					0			// 0x00000000 generic damage was done
#define DMG_CRUSH					(1<<0)		// 0x00000001 crushed by falling or moving object.
#define DMG_BULLET					(1<<1)		// 0x00000002 shot
#define DMG_SLASH					(1<<2)		// 0x00000004 cut, clawed, stabbed
#define DMG_BURN					(1<<3)		// 0x00000008 heat burned (- fire icon)
#define DMG_FREEZE					(1<<4)		// 0x00000010 frozen
#define DMG_FALL					(1<<5)		// 0x00000020 fell too far
#define DMG_BLAST					(1<<6)		// 0x00000040 explosive blast damage
#define DMG_CLUB					(1<<7)		// 0x00000080 crowbar, punch, headbutt
#define DMG_SHOCK					(1<<8)		// 0x00000100 electric shock
#define DMG_SONIC					(1<<9)		// 0x00000200 sound pulse shockwave
#define DMG_ENERGYBEAM				(1<<10)		// 0x00000400 laser or other high energy beam
#define DMG_PREVENT_PHYSICS_FORCE	(1<<11)		// 0x00000800 Prevent a physics force
#define DMG_NEVERGIB				(1<<12)		// 0x00001000 with this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB				(1<<13)		// 0x00002000 with this bit OR'd in, any damage type can be made to gib victims upon death.
#define DMG_DROWN					(1<<14)		// 0x00004000 Drowning
#define DMG_PARALYZE				(1<<15)		// 0x00008000 slows affected creature down
#define DMG_NERVEGAS				(1<<16)		// 0x00010000 nerve toxins, very bad	(- radiation icon???)
#define DMG_POISON					(1<<17)		// 0x00020000 blood poisoning - heals over time like drowning damage
#define DMG_RADIATION				(1<<18)		// 0x00040000 radiation exposure (- lightning icon???)
#define DMG_DROWNRECOVER			(1<<19)		// 0x00080000 drowning recovery
#define DMG_ACID					(1<<20)		// 0x00100000 toxic chemicals or acid burns (- oxygen icon???)
#define DMG_SLOWBURN				(1<<21)		// 0x00200000 in an oven (- fire icon)
#define DMG_SLOWFREEZE				(1<<22)		// 0x00400000 in a subzero freezer
#define DMG_MORTAR					(1<<23)		// 0x00800000 Hit by air raid (done to distinguish grenade from mortar)

// CS Specific
#define DMG_HEGRENADE				(1<<24)		// 0x01000000 #define DMG_PLASMA (1<<24) // Shot by Cremator




// FadeFlags. Used with EFFECT_ScreenFade()
#define FFADE_IN					0			// Just here so we don't pass 0 into the function
#define FFADE_OUT					(1<<0)		// Fade out (not in)
#define FFADE_MODULATE				(1<<1)		// Modulate (don't blend)
#define FFADE_STAYOUT				(1<<2)		// ignores the duration, stays faded out until new ScreenFade message received


// Helpers
#define IsValidUser(%1)				( 1 <= %1 <= GameInfo[GI_MaxPlayers] )
#define IsValidSkill(%1)			( 0 <= %1 < MAX_SKILLS )
#define IsValidAttribute(%1)		( 0 <= %1 < MAX_ATTRIBUTES )
#define IsValidClass(%1)			( 1 <= %1 <= MAX_CLASSES )
#define IsOnTeam(%1)				( PlayerInfo[%1][PI_TeamID] == TEAM_T || PlayerInfo[%1][PI_TeamID] == TEAM_CT )

// Packed color helpers
#define COLOR_RGBA(%1,%2,%3,%4)		(((%1&255)<<24)|((%2&255)<<16)|((%3&255)<<8)|(%4&255))
#define COLOR_RGB(%1,%2,%3)			(((%1&255)<<24)|((%2&255)<<16)|((%3&255)<<8))
#define COLOR_RED(%1)				((%1>>24)&255)
#define COLOR_GREEN(%1)				((%1>>16)&255)
#define COLOR_BLUE(%1)				((%1>>8)&255)
#define COLOR_ALPHA(%1)				(%1&255)


#define M_PI						3.1415926535
#define M_PI2						6.2831853072
